package b.olap

object CubeMngr {
  val SQL_COLS = "SELECT c_name, c_label, c_type, c_width, c_input FROM t_ec_cols WHERE c_cube = ? order by c_sno"
  val SQL_DIM_DEFS = "SELECT c_dim, c_value, c_label FROM t_ec_dim_defs WHERE c_cube = ? order by c_dim, c_sno"

  def dig2(c: Cube, dims: List[String], digSegment: Option[String] = None) = {
    val sbCols = "'all', " + dims.mkString(", ")
    val sbGrps = if (dims.length > 1) "GROUP BY " + dims.mkString(", ") else ""
    val qryCond = (c.whereSegment.toList ++ digSegment.toList).mkString(", ")
    val sbWhere = if (qryCond.nonEmpty) s"WHERE $qryCond" else ""
    val sb = s"SELECT $sbCols${c.sqlSegment}$sbWhere"
  }
}
